1.2.3.7. alpha.cplusplus.UninitializedObject (C++)
This checker reports uninitialized fields in objects created after a constructor call. It doesn't only find direct uninitialized fields, but rather makes a deep inspection of the object, analyzing all of it's fields subfields. The checker regards inherited fields as direct fields, so one will recieve warnings for uninitialized inherited data members as well.
Examples:
// With Pedantic and CheckPointeeInitialization set to true struct A { struct B { int x; // note: uninitialized field 'this->b.x' // note: uninitialized field 'this->bptr->x' int y; // note: uninitialized field 'this->b.y' // note: uninitialized field 'this->bptr->y' }; int *iptr; // note: uninitialized pointer 'this->iptr' B b; B *bptr; char *cptr; // note: uninitialized pointee 'this->cptr' A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {} }; void f() { A::B b; char c; A a(&b, &c); // warning: 6 uninitialized fields // after the constructor call } // With Pedantic set to false and // CheckPointeeInitialization set to true // (every field is uninitialized) struct A { struct B { int x; int y; }; int *iptr; B b; B *bptr; char *cptr; A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {} }; void f() { A::B b; char c; A a(&b, &c); // no warning } // With Pedantic set to true and // CheckPointeeInitialization set to false // (pointees are regarded as initialized) struct A { struct B { int x; // note: uninitialized field 'this->b.x' int y; // note: uninitialized field 'this->b.y' }; int *iptr; // note: uninitialized pointer 'this->iptr' B b; B *bptr; char *cptr; A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {} }; void f() { A::B b; char c; A a(&b, &c); // warning: 3 uninitialized fields // after the constructor call }